//
//  TransactionDetailTableVC.m
//  DaoZiJinFu
//
//  Created by woker on 16/6/28.
//  Copyright © 2016年 iwoker. All rights reserved.
//

#import "TransactionDetailTableVC.h"
#import "TransSuccessCell.h"

@interface TransactionDetailTableVC () {
    NSArray *listArray;
    NSArray *dataArray;
}

@end

@implementation TransactionDetailTableVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupTitleView:@"交易详情"];
    self.view.backgroundColor = BACKGROUND_COLOR;
    [self leftButton:nil];
    
    listArray = @[@"交易类型",@"交易金额",@"剩余可用金额",@"交易时间",@"交易单号"];
    dataArray = @[@"客户充值",@"1000元",@"2000元",@"2015-06-21 12:12:30",@"201566066060606"];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (!section) {
        return 1;
    } else {
        return 5;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (!indexPath.section) {
        return 80;
    } else {
        return 64;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell;
    [tableView registerNib:[UINib nibWithNibName:@"TransSuccessCell" bundle:nil] forCellReuseIdentifier:TRANSSUC_CELL];
    if (!indexPath.section) {
        TransSuccessCell *sucCell = [TransSuccessCell cellWithTableView:tableView];
        sucCell.status = [_model.status integerValue];
        sucCell.order_type = [_model.order_type integerValue];
        [sucCell setUpCell];
        cell = sucCell;
    }
    else {
        cell = [tableView dequeueReusableCellWithIdentifier:TRANSDETAIL_CELL];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:TRANSDETAIL_CELL];
        }
        cell.textLabel.textColor = DEFAULTCOLOR;
        cell.textLabel.font = [UIFont systemFontOfSize:15];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
        cell.textLabel.text = listArray[indexPath.row];
        if (indexPath.row == 0) {
            cell.detailTextLabel.text = _model.transaction_type;
        } else if (indexPath.row == 1) {
            cell.detailTextLabel.text = _model.transaction_amount;
        } else if (indexPath.row == 2) {
            float money = [DZNsstringUtil floatInto:[_model.account_balance doubleValue]];
            cell.detailTextLabel.text = [NSString stringWithFormat:@"%.2lf",money];
        } else if (indexPath.row == 3) {
            cell.detailTextLabel.text = _model.transaction_time;
        } else if (indexPath.row == 4) {
            cell.detailTextLabel.text = _model.order_sn;
        }
    }
    
    return cell;
}

@end
